package Nisha.polymorphism;

import java.util.Scanner;

/**
 *  type casting with interfaces. create 2 different interfaces with same method and an implementation class. 
 *  Then create a reference to one interface 
 *  and create an object for it using implementation class. Then type cast to other interface and use it.
 * @author ivy4281
 *
 */
interface Hello
{
	public void sayIt();
}


interface Hi
{
	public void sayIt();
}

public class polymorphismOverriding implements Hello,Hi {


	@Override
	public void sayIt() {
		
		System.out.println("Hello and Hi");
		
	}
	
	  public static void insertionSort(int[] A){
		  for(int i = 1; i < A.length; i++){
		    int value = A[i];
		    int j = i - 1;
		    while(j > 0 && A[j] > value){
		      A[j + 1] = A[j];
		      j = j - 1;
		    }
		    A[j + 1] = value;
		  }
		        
		        printArray(A);
		}

		    
		    static void printArray(int[] ar) {
		         for(int n: ar){
		            System.out.print(n+" ");
		         }
		      }
	public static void main(String args[])
	{
		/*Hello hello = new polymorphismOverriding();
		Hi hi = (Hi)hello;
		hello.sayIt();
		hi.sayIt();	*/
		 Scanner in = new Scanner(System.in);
	     int n = in.nextInt();
	     int[] ar = new int[n];
	     for(int i=0;i<n;i++){
	        ar[i]=in.nextInt(); 
	     }
	     insertionSort(ar);
	
		
	}

}
